﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Styx;
using Styx.Plugins;
using Styx.Common;
using Styx.CommonBot;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using System.Net.Mail;
using System.Net;

namespace rndbuddy
{
    static class LogWatcher
    {
        //public static int stuck_counter = 0;

        public static void Logging_OnLogMessage(System.Collections.ObjectModel.ReadOnlyCollection<Logging.LogMessage> messages)
        {
            List<Logging.LogMessage> StuckMessages = messages.Where(o => o.Message.Contains("We are stuck")).ToList();
            foreach (Logging.LogMessage Item in StuckMessages)
            {
                movement_controller.check_stuck();
                //jumpy ;)
                movement_controller.jump();
            }

            //crowdsource when there's a approach
            List<Logging.LogMessage> appr = messages.Where(o => o.Message.Contains("Approaching")).ToList();
            foreach (Logging.LogMessage Item in appr)
            {
                crowdsourcer.get_nodes();
            }

            //event after a node has been harvested
            List<Logging.LogMessage> harv = messages.Where(o => o.Message.Contains("Harvested")).ToList();
            if (harv.Count > 0)
            {
                if (settings.jump)
                    movement_controller.jump();

                if (settings.followers_detection)
                {
                    PlayerSecurity.PlayerFollowDetection();
                    PlayerSecurity.analyze_followers();
                }
            }

            //increase moved counter if we are stuck due to singular
            List<Logging.LogMessage> recov = messages.Where(o => o.Message.Contains("Waiting to recover our h")).ToList();
            if (recov.Count > 0)
            {
                //if (settings.jump)
                //    movement_controller.jump();
                //still have to think about it...

                movement_watcher.moved += 100;
            }
        }

    }
}
